import request from '@/utils/request.js'

// 发送
export function articlesInfo (id) {
  return request({
    url: `/v1_0/articles/${id}`
  })
}
// 关注
export function userFollowings (target, bol = true) {
  if (bol) {
    // 关注
    return request({
      url: '/v1_0/user/followings',
      methods: 'post',
      data: {
        target
      }
    })
  } else {
    // 取消关注
    return request({
      url: '/v1_0/user/followings/' + target,
      method: 'delete'
    })
  }
}

export function commentsGet (params) {
  return request({
    url: '/v1_0/comments',
    params
  })
}

// 点赞
export function articleLikings (target, bol = true) {
  if (bol) {
    // 点赞
    return request({
      url: '/v1_0/article/likings',
      method: 'post',
      data: {
        target
      }
    })
  } else {
    return request({
      url: '/v1_0/article/likings/' + target,
      method: 'DELETE'
    })
  }
}
// 回复评论
export function commentsPost (data) {
  return request({
    url: '/v1_0/comments',
    method: 'post',
    data
  })
}
